import allure

from page_element.roncoo_power_manage import select_pe
from page_object.roncoo_login import RoncooLogin
from page_element.el_A3mall import *
import logging
from utils.timer import sleep


class Select_Power(RoncooLogin):
    """查询权限"""

    def page_select_power_login(self, powername,casename,expected):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击权限管理"):
            self.click(select_pe.power_manage)
            sleep(2)
        with allure.step(f"点击权限管理"):
            self.click(select_pe.power_manage2)
            sleep(2)
        with allure.step(f"输入权限名称"):
            self.send_keys(select_pe.power_name,powername)
            sleep(2)
        with allure.step(f"点击查询"):
            self.click(select_pe.query_bth)
            sleep(2)
        with allure.step(f"断言权限名称"):
            if casename == "正确的权限名称":
                dy = self.text(select_pe.dy)
                assert expected == dy
            else:
                dy2 = self.text(select_pe.dy2)
                assert expected == dy2


